package com.dxf.chepter02

object T12_算数 {
  def main(args: Array[String]): Unit = {
    // 1除法 /
    var r1: Int = 10 / 3
    println(r1)
    var r2: Double = 10 / 3 // 整数相除,保留整数部分,并复制给Double
    println(r2)
    var r3: Double = 10.0 / 3 //转double相除
    println(r3)
    println("r3=" + r3.formatted("%.2f"))

    //2 取模 %
    // a % b= a- ( a/b *b)      -->    5 % 3    =     5 - (5 / 3 * 3)

    println(10 % 3) // 10- (10 / 3 * 3) =1
    println(-10 % 3) // -10 - (-10 / 3 * 3) = -1


  }
}
